﻿#pragma once

#include <windows.h>

#define GDIPVER 0x0110 //定义高版本的GDI+(1.1)部分功能需要1.1版本才能使用
#include <gdiplus.h>


using namespace Gdiplus;//使用Gdiplus命名空间

namespace DarkMoonUI {
    bool DrawNineGridImage(Graphics* graphics, Image* image, float destX, float destY, float destWidth, float destHeight,
        int gridLeft, int gridRight = -1, int gridTop = -1, int gridBottom = -1, Unit srcUnit = UnitPixel, ImageAttributes* imgAttr = nullptr);
    void DrawRoundedRectangle(Graphics* graphics, Pen* pen, Brush* brush, float x, float y,
        float width, float height, float cornerRadius);
    class zyBuffGraphics {
    public:
        
        zyBuffGraphics();
        ~zyBuffGraphics();
		//@别名 销毁()
		void Destory();
        HDC gethdc() const;
        Gdiplus::Graphics* GetGraphics() const;
		//@别名 创建()
        BOOL Create(int Width, int Height, HDC hdc = NULL);
        BOOL Create(int Width, int Height, HDC hdc, bool useAlpha);
		//@备注 此方法不支持透明，但速度最快
		//@别名 复制()
        BOOL Copy2dc(HDC hdc, int x, int y, int w, int h, int x1, int y1, UINT rop = SRCCOPY) const;
        BOOL Copy2dc(HDC hDest, int x, int y, int w, int h, int xSrc = 0, int ySrc = 0) const;
        void Clear();
    private:
        //ULONG_PTR m_pGdiToken = 0;
        HDC m_hdc = nullptr;         // 缓冲设备上下文
        HBITMAP m_hBitmap = nullptr; // DIB位图句柄
        Gdiplus::Graphics* m_pGraphics = nullptr; // GDI+绘图对象
        int m_Width = 0;
        int m_Height = 0;
        bool m_hasAlpha = false;     // 新增：Alpha通道标志
    };

   
}
